<?
//Import Classes
	require_once('classes/session.php');
	require_once('classes/sql_wtc.php');
	require_once('classes/functions.php');
	require_once('classes/country.php');
	
//Redirect ?	
	if (isset($_SESSION['user'])&&$_SESSION['user'][1]) {
		header("Location: check_out_delivery_details.php");
		exit();
	}

//Connect to DB
	
	$myDB = new MySQL_class();
	$myDB->Create();
	
//Get Parameters
	if (isset($_GET['email'])) {
		$email=$_GET['email'];
		$msg  = "<br><font class=\"s7\">User $email registered successfully . <br> You can use your new account to login now .</font><br><br>";
	}
	else {
		$email='';
		$msg='';
	}
	
	$user=array();
	$_SESSION['user']=$user;
	
	if (isset($_POST['act'])&&$_POST['act']=='login'){
		$email		=	trim($_POST['email']);
		$password	=	addslashes(encrypt(trim($_POST['password']),$email));
		$sql	= "select * from cus_info where email='$email' and password='$password';";
		$myDB->Query($sql);
		if (!$myDB->rows) {
			//echo $myDB->rows;
			$msg = "<br><font class=\"s7\">Invaild email and password . <br> Please check your password and email address .</font><br><br>";
		}
		else {
			$rec	= mysql_fetch_object($myDB->result);
			$user[0]= $rec->id;
			$user[1]= $rec->email;
			$user[2]= $rec->firstname;
			$user[3]= $rec->lastname;
			$user[4]= $rec->address;
			$user[5]= $rec->tel;
			$user[6]= $rec->zipcode;
			$user[7]= $rec->fax;
			$user[8]= $rec->country;
			$user[9]= $rec->hkid;
			$user[10]=$rec->sex;
			$_SESSION['user']=$user;

			@mysql_close();
			header("Location: check_out_delivery_details.php");
			exit();
		}
	}


//Functions	

	$menuhtml		= buildMenu($cat_lev,$category,$cat_par,'product.php');

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>Jonesky eShopping</title>


<link href="css/main.css" rel="stylesheet" type="text/css">

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>

<body>
<table width="770" align="center" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="85" align="center" valign="top">
	  <table width="100%" height="84"  border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="205" rowspan="3" align="center" valign="middle" background="images/index_LOGO_t1-1.gif">&nbsp;</td>
          <td width="1" rowspan="3"></td>
          <td height="57" align="right" background="images/index_CH_t1-2-1.gif"><table width="430" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="425" height="34" align="right" background="images/index_CH_t1-2-1-2.gif"><a href="../Jonesky_CH/sign_in.php"><img src="images/jonesky_chinese.gif" border="0"></a></td>
			  <td width="5"></td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td height="1"></td>
        </tr>
        <tr>
          <td height="26" align="right" background="images/index_SVC_t1-2-2.gif"><table width="" height="18" border="0" cellpadding="0" cellspacing="0">
            <tr align="left" valign="middle">
              <td width="115"><a class=s3 href="shipping_charge_list.php">- Shipping Charge </a></td>
              <td width="75"><a class=s3 href="view_cart.php">- View Cart </a></td>
              <td width="75"><a class=s3 href="check_out_delivery_details.php">- Check Out</a> </td>
              <td width="155"><a class=s3 href="claim.php">- Redemption Centre Info </a></td>
            </tr>
          </table></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td height="111" bgcolor="#FF0000"><img src="images/<?=randomBanner()?>" width="770" height="111"></td>
  </tr>
    <tr>
    <td height="1"></td>
  </tr>
  <tr>
    <td height="475" valign="top"><table width="100%" height="475"  border="0" cellpadding="0" cellspacing="0" class="mytd">
      <tr>
        <td height="31"><table width="100%" height="31"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="710" background="images/red_navigate.gif"><table width="100%" height="31"  border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="43" align="center"><a class=s3 href="index_eng.php">Home</a></td>
                <td width="1"><img src="images/whiteLine.gif"></td>
                <td width="59" align="center"><a class=s3 href="about_us.php">About us </a></td>
                <td width="1"><img src="images/whiteLine.gif"></td>
                <td width="86" align="center"><a class=s3 href="new_products.php">New Products </a></td>
                <td width="1"><img src="images/whiteLine.gif"></td>
                <td width="68" align="center"><a class=s3 href="promotion.php">Promotion</a></td>
                <td width="1"><img src="images/whiteLine.gif"></td>
                <td width="33" align="center"><a class=s3 href="faq.php">FAQ</a></td>
                <td width="1"><img src="images/whiteLine.gif"></td>
                <td width="130" align="center"><a class=s3 href="terms_and_condition.php">Terms and Conditions</a></td>
                <td width="1"><img src="images/whiteLine.gif"></td>
                <td width="83" align="center"><a class=s3 href="return_policy.php">Return Policy </a></td>
                <td width="1"><img src="images/whiteLine.gif"></td>
                <td width="93" align="center"><a class=s3 href="delivery_policy.php">Delivery Policy</a> </td>
                <td width="1"><img src="images/whiteLine.gif"></td>
                <td width="71" align="center"><a class=s3 href="contact_us.php">Contact us </a></td>
                <td width="1"><img src="images/whiteLine.gif"></td>
                <td width="35" align="center"><a class=s3 href="news.php">News</a></td>
              </tr>
            </table></td>
            <td><img src="images/red_navigate_right.gif" width="36" height="31"></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td height="381"><table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="4"></td>
            <td width="192" valign="top">
			<table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="2" bgcolor="#FFFFFF"></td>
                <td width="184" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="2" bgcolor="#FFFFFF"></td>
                  </tr>
                  <tr>
                    <td height="28"><img src="images/products0.gif" width="184" height="28"></td>
                  </tr>
                  <tr>
                    <td height="2" bgcolor="#FFFFFF"></td>
                  </tr>
                  <tr>
                    <td height="80" background="images/products3.jpg">
                      <form name="searchbox" action="product_search_result.php" method="post"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td height="20">&nbsp;&nbsp;&nbsp;&nbsp;<a class=s2>Keywords</a></td>
                        </tr>
                        <tr>
                          <td>&nbsp;&nbsp;&nbsp;<input name="search" type="text" class="text" id="search" size="20"></td>
                        </tr>
                        <tr>
                          <td height="28">&nbsp;&nbsp;&nbsp;<input name="submit" type="submit" class="button" id="submit" onClick="MM_validateForm('search','','R');return document.MM_returnValue" value="Search"></td>
                        </tr>
                      </table></form>
</td>
                  </tr>
					<?=$menuhtml?>
                </table></td>
                <td width="6" valign="top" background="images/index_SVC_t1-2-2.jpg">&nbsp;</td>
              </tr>
              <tr>
                <td width="2" bgcolor="#FFFFFF"></td>
                <td height="12" background="images/Pro_Search_bottom.gif">&nbsp;</td>
                <td width="6"><img src="images/Pro_Search_circle.gif" width="6" height="12"></td>
              </tr>
            </table>
			</td>
            <td width="574" valign="top">	<form name="form1" id="form1" action="" method="POST"><table border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#E6E6E6">
        <tr> 
          <td height="65" valign="bottom"><img src="images/procedure2.gif" width="562" height="50"></td>
        </tr>
        <tr>
          <td height="25"><?=$msg?></td>
        </tr>
        <tr> 
          <td class="s4">&nbsp;&nbsp;&nbsp;Your Registered Email:<br>
            &nbsp;&nbsp;&nbsp;<input name="email" type="text" class="text" id="email" value="<?=$email?>" size="30"> </td>
        </tr>
        <tr> 
          <td><span class="s4">&nbsp;&nbsp;&nbsp;Password :</span><br>
            &nbsp;&nbsp;&nbsp;<input name="password" type="password" class="text" id="password" size="30">
          </td>
        </tr>
        <tr> 
          <td height="41">&nbsp;&nbsp;&nbsp;<input name="submit" type="image" id="submit" onClick="MM_validateForm('email','','RisEmail','password','','R');return document.MM_returnValue" src="images/submit.gif" width="78" height="19" border="0">
            <input name="act" type="hidden" id="act" value="login"></td>
        </tr>
        <tr> 
          <td height="34">&nbsp;&nbsp;&nbsp;<img src="images/info.jpg" width="16" height="18"> <a href="forgot_signin_details.php" class="s4">Forgot 
            sign-in details?</a></td>
        </tr>
        <tr> 
          <td height="122">&nbsp;<a href="join_us_agreement.php"><img src="images/join_as_New.gif" width="161" height="19" border="0"></a> 
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
            <a href="product.php"><img src="images/continue_to_PUR.gif" width="161" height="19" border="0"></a> 
            &nbsp;&nbsp;&nbsp;&nbsp; </td>
        </tr>
      </table></form>
      <br>
      <br>
			
			&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
          <td height="80" align="center" valign="bottom" bgcolor="#FFFFFF"><span class="s1">Copyright 
            &copy; 2004, All Rights Reserved by Jonesky Limited. <br>
            &nbsp;&nbsp; </span></td>
      </tr>
    </table></td>
  </tr>

</table>
</body>
</html>
<?
@mysql_close();
?>